package cn.framelife.rainbow.db.mysql;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.Statement;

import cn.framelife.rainbow.db.BaseTable;

/**
 * mysql的数据表相关
 * 
 * @author 潘广伟 p_3er@qq.com  
 * @date 2014-1-6 下午6:25:37
 */
public class MySQLTable extends BaseTable{

	public MySQLTable(String tableName, DatabaseMetaData metaData) {
		super(tableName, metaData);
	}

	public String getTableComment(String tableName, Connection conn) throws Exception {
		Statement st = null;
		ResultSet rs = null;
		String result = tableName;
		st = conn.createStatement();
		rs = st.executeQuery("SELECT TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='"
				+ tableName + "'");
		while (rs.next()) {
			result = rs.getString(1);
			if(!result.equals("Users and global privileges")){
				break;
			}
			
		}
		return result;
	}
}
